package com.ihg.hiex.admin.dao.account;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.entity.data.ElearningSource;
import com.ihg.hiex.entity.user.Assessor;

/**
 * @author Guangli Yan
 *
 */
@Dao("hibernate")
public interface AssessorDao {
    
    /**
     * 
     * @param currentSessionId
     * @return
     */
    @Query("FROM Assessor WHERE disabled = false AND (currentSessionId != :currentSessionId OR currentSessionId IS NULL) AND currentCertificateRecordId IS NULL")
    public List<Assessor> list(@Variable("currentSessionId") Long currentSessionId);
    
    /**
     * 
     * @return
     */
    @Query("SELECT COUNT(1) FROM Assessor WHERE disabled = false AND currentSessionId is null")
    public int count();
    
    /**
     * 
     * @param beginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM Assessor WHERE disabled = false AND currentSessionId is null ORDER BY createTime")
    public List<Assessor> list(@Variable("beginIndex")int beginIndex, @Variable("maxResult") int maxResult);

	/**
	 * 
	 * @param email
	 * @return
	 */
	@Query("FROM Assessor WHERE disabled = false AND email =:email")
	public Assessor loadByEmail(@Variable("email") String email);
	
	/**
	 * 
	 * @param ids
	 * @return
	 */
	@Query("FROM Assessor WHERE disabled = false AND id IN (:ids)")
	public List<Assessor> list(@Variable("ids") List<Long> ids);
	
	/**
	 * 
	 * @param courseIds
	 * @return
	 */
	@Query("FROM ElearningSource WHERE disabled = false AND courseId in(:courseIds)")
	public List<ElearningSource> listElearningSource(@Variable("courseIds") String[] courseIds);

}
